package com.ruoyi.web.controller.gym;

import com.ny.domain.MemberCardDO;
import com.ny.domain.MemberConsumptionDO;
import com.ny.domain.MemberDO;
import com.ny.domain.MemberLevelDO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.MemberCardDTO;
import com.ny.dto.MemberConsumptionDTO;
import com.ny.dto.MemberDTO;
import com.ny.dto.MemberLevelDTO;
import com.ny.dto.RestResult;
import com.ny.dto.UpdateGroup;
import com.ny.query.MemberQuery;
import com.ny.query.QueryGroup;
import com.ny.service.MemberService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 会员管理模块
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("会员管理模块")
@RequestMapping("member")
@RestController
public class MemberController extends BaseController {

    @Autowired
    private MemberService memberService;

    @GetMapping("/list")
    public TableDataInfo queryMemberList(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize) {
        List<MemberDO> memberDOS = memberService.queryMemberList(pageNum, pageSize);
        return getDataTable(memberDOS);
    }

    /**
     * 新增会员
     *
     * @param memberDTO 会员信息
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation("新增会员")
    @ResponseBody
    public RestResult<Boolean> addMember(@RequestBody @Validated(CreateGroup.class) MemberDTO memberDTO) {
        Boolean result = memberService.addMember(memberDTO);
        return RestResult.success(result);
    }

    /**
     * 删除会员
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @ApiOperation("删除会员")
    @ResponseBody
    public RestResult<Boolean> deleteMember(@RequestBody @Validated(DeleteGroup.class) MemberQuery memberQuery) {
        Boolean result = memberService.deleteMember(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 更新会员信息
     *
     * @param memberDTO 会员信息
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation("更新会员信息")
    @ResponseBody
    public RestResult<Boolean> updateMember(@RequestBody @Validated(UpdateGroup.class) MemberDTO memberDTO) {
        Boolean result = memberService.updateMember(memberDTO);
        return RestResult.success(result);
    }

    /**
     * 查询会员信息
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ApiOperation("查询会员信息")
    public RestResult<MemberDO> getMemberInfo1(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        MemberDO result = memberService.getMemberInfo1(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 办理会员卡
     *
     * @param memberCardDTO 会员卡信息
     * @return
     */
    @RequestMapping(value = "/card/add", method = RequestMethod.POST)
    @ApiOperation("办理会员卡")
    @ResponseBody
    public RestResult<Boolean> addMemberCard(@RequestBody @Validated(CreateGroup.class) MemberCardDTO memberCardDTO) {
        Boolean result = memberService.addMemberCard(memberCardDTO);
        return RestResult.success(result);
    }

    /**
     * 充值会员卡
     *
     * @param memberCardDTO 会员卡信息
     * @return
     */
    @RequestMapping(value = "/card/recharge", method = RequestMethod.POST)
    @ApiOperation("充值会员卡")
    @ResponseBody
    public RestResult<Boolean> rechargeMemberCard(@RequestBody @Validated(UpdateGroup.class) MemberCardDTO memberCardDTO) {
        Boolean result = memberService.rechargeMemberCard(memberCardDTO);
        return RestResult.success(result);
    }

    /**
     * 续期会员卡
     *
     * @param memberCardDTO 会员卡信息
     * @return
     */
    @RequestMapping(value = "/card/renew", method = RequestMethod.POST)
    @ApiOperation("续期会员卡")
    @ResponseBody
    public RestResult<Boolean> renewMemberCard(@RequestBody @Validated(UpdateGroup.class) MemberCardDTO memberCardDTO) {
        Boolean result = memberService.renewMemberCard(memberCardDTO);
        return RestResult.success(result);
    }

    /**
     * 查询会员卡信息
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/card/info", method = RequestMethod.GET)
    @ApiOperation("查询会员卡信息")
    public RestResult<List<MemberCardDO>> getMemberCardInfo(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        List<MemberCardDO> result = memberService.getMemberCardInfo(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 新增会员消费记录
     *
     * @param memberConsumptionDTO 消费记录信息
     * @return
     */
    @RequestMapping(value = "/consumption/add", method = RequestMethod.POST)
    @ApiOperation("新增会员消费记录")
    @ResponseBody
    public RestResult<Boolean> addMemberConsumption(@RequestBody @Validated(CreateGroup.class) MemberConsumptionDTO memberConsumptionDTO) {
        Boolean result = memberService.addMemberConsumption(memberConsumptionDTO);
        return RestResult.success(result);
    }

    /**
     * 查询会员消费记录
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/consumption/info", method = RequestMethod.GET)
    @ApiOperation("查询会员消费记录")
    public RestResult<List<MemberConsumptionDO>> getMemberConsumptionInfo(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        List<MemberConsumptionDO> result = memberService.getMemberConsumptionInfo(memberQuery);
        return RestResult.success(result);
    }

    /**
     * 新增会员等级
     *
     * @param memberLevelDTO 会员等级信息
     * @return
     */
    @RequestMapping(value = "/level/add", method = RequestMethod.POST)
    @ApiOperation("新增会员等级")
    @ResponseBody
    public RestResult<Boolean> addMemberLevel(@RequestBody @Validated(CreateGroup.class) MemberLevelDTO memberLevelDTO) {
        Boolean result = memberService.addMemberLevel(memberLevelDTO);
        return RestResult.success(result);
    }

    /**
     * 更新会员等级
     *
     * @param memberLevelDTO 会员等级信息
     * @return
     */
    @RequestMapping(value = "/level/update", method = RequestMethod.PUT)
    @ApiOperation("更新会员等级")
    @ResponseBody
    public RestResult<Boolean> updateMemberLevel(@RequestBody @Validated(UpdateGroup.class) MemberLevelDTO memberLevelDTO) {
        Boolean result = memberService.updateMemberLevel(memberLevelDTO);
        return RestResult.success(result);
    }

    /**
     * 查询会员等级信息
     *
     * @param memberQuery 查询条件
     * @return
     */
    @RequestMapping(value = "/level/info", method = RequestMethod.GET)
    @ApiOperation("查询会员等级信息")
    public RestResult<MemberLevelDO> getMemberLevelInfo1(@Validated(QueryGroup.class) MemberQuery memberQuery) {
        MemberLevelDO result = memberService.getMemberLevelInfo1(memberQuery);
        return RestResult.success(result);
    }
}
